import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// 饿了么
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    // 饿了么
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server:{
    host:true,
    port:51732,
    proxy:{
      '/api': {
        target: 'http://localhost:51733',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
      '/img': {
        target: 'http://localhost:51733',
        changeOrigin: true,
      },
      '/photo/': {
        target: 'http://localhost:51733',
        changeOrigin: true,
      },
      '/temline': {
        target: 'http://localhost:51733',
        changeOrigin: true,
      },
      '/tx/': {
        target: 'http://localhost:51733',
        changeOrigin: true,
      },
      '/icons/': {
        target: 'http://localhost:51733',
        changeOrigin: true,
      },
    }
  }
})
